package behavioral.chainOfResponsibility;

public abstract class Handler {
    private Handler next;

    public Handler() {
        this.next = null;
    }

    public Handler(Handler next) {
        this.next = next;
    }

    public void handle(HttpRequest request) {
        if (doHandle(request) && next != null) {
            next.handle(request);
        }
    }

    public abstract boolean doHandle(HttpRequest request);

    public void setNext(Handler next) {
        this.next = next;
    }
}
